//
//  DetailsBtnViewController.m
//  Ai
//
//  Created by 杜超男 on 2019/3/14.
//  Copyright © 2019年 杜超男. All rights reserved.
//

#import "DetailsBtnViewController.h"
//#import "Masonry.h"
#import "Masonry.h"
#import "DetailsBtnTableViewCell.h"
#import "XLSlideSwitch.h"//滑动滚动第三方
#import "PositiveLanguageViewController.h"//正规语言
#import "IllegalLanguageWarningViewController.h"//违规语言告警
#import "ClassLanguageSummaryViewController.h"//安静指数
#import "ClassLanguageCollectViewController.h"
@interface DetailsBtnViewController ()<UITableViewDelegate , UITableViewDataSource , XLSlideSwitchDelegate>
@property (nonatomic , strong)UITableView *tableView;
@property (nonatomic , strong)XLSlideSwitch *ScrollView;///滚动视图
@end

@implementation DetailsBtnViewController
-(void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBar.hidden = NO;
    self.tabBarController.tabBar.hidden = YES;
    //发送通知告诉  控制器   展示方式是通过  点击详情按钮
    [[NSNotificationCenter defaultCenter] postNotificationName:@"Mode" object:nil userInfo:nil];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    UIView *BackgroundColorView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
    BackgroundColorView.backgroundColor = [UIColor colorWithRed:240/255.0 green:240/255.0 blue:240/255.0 alpha:1];
    [self.view addSubview:BackgroundColorView];
    [BackgroundColorView sendSubviewToBack:self.view];
    BackgroundColorView.translatesAutoresizingMaskIntoConstraints = NO;
    [BackgroundColorView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view.mas_safeAreaLayoutGuideTop).inset(0);
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
    
    //创建一个数组用来存储名字
    NSArray *TitlesArr = @[@"正规语言" , @"违规语言告警" , @"安静指数"];
    NSArray *ControllersArr = @[@"PositiveLanguageViewController" , @"IllegalLanguageWarningViewController" , @"ClassLanguageSummaryViewController"];
    NSMutableArray *ViewControllers = [[NSMutableArray alloc] init];
    for (int i = 0 ; i < TitlesArr.count; i ++) {
        //字符串创建控制器
        UIViewController *VC = [[NSClassFromString(ControllersArr[i])alloc] init];
        [ViewControllers addObject:VC];
    }
    //滚动视图
    _ScrollView = [[XLSlideSwitch alloc] initWithFrame:CGRectMake(0, 16, self.view.bounds.size.width, self.view.bounds.size.height - 64) Titles:TitlesArr viewControllers:ViewControllers];
    _ScrollView.delegate = self;
    //rgba(102/255.0, 102, 102, 1)
    _ScrollView.itemNormalColor = [UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1];
    //rgba(72/255.0, 169/255.0, 54/255.0, 1)
    _ScrollView.itemSelectedColor = [UIColor colorWithRed:72/255.0 green:169/255.0 blue:54/255.0 alpha:1];
    _ScrollView.customTitleSpacing = 30;
    _ScrollView.hideShadow=YES;
    [_ScrollView showInViewController:self];
    _ScrollView.backgroundColor = [UIColor colorWithRed:240/255.0 green:240/255.0 blue:240/255.0 alpha:1];
    [_ScrollView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.mas_equalTo(self.view.mas_safeAreaLayoutGuideTop).inset(190);
        make.right.mas_equalTo(0);
        make.bottom.mas_equalTo(-0);
    }];
    
    self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"2018年10月";
    [self.view addSubview:self.tableView];
//    self.tableView.translatesAutoresizingMaskIntoConstraints = NO;
    [_tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(self.view.mas_safeAreaLayoutGuideTop).inset(0);
        make.bottom.mas_equalTo(self.view.mas_safeAreaLayoutGuideBottom).inset(580);
    }];
    
    // Do any additional setup after loading the view.
}
-(UITableView *)tableView{
    _tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStyleGrouped];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.backgroundColor = [UIColor clearColor];
    _tableView.scrollEnabled = NO;
    _tableView.rowHeight = 170;
    [_tableView registerNib:[UINib nibWithNibName:@"DetailsBtnTableViewCell" bundle:nil] forCellReuseIdentifier:@"DetailsBtnTableViewCell"];
    return _tableView;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    DetailsBtnTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DetailsBtnTableViewCell"];
    if (!cell) {
        cell = [[DetailsBtnTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"DetailsBtnTableViewCell"];
    }
    cell.selectionStyle = 0;
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 10)];
    headerView.backgroundColor = [UIColor clearColor];
    return headerView;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
